package com.heima.article.service.impl;

import com.heima.article.service.IAbc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@Service
public class IAbcImpl implements IAbc {

    @Resource
    private RedisTemplate<String,Object> redisTemplate;


    @Override
    public String abc() {
        redisTemplate.opsForValue().set("ABC","1",1,TimeUnit.MINUTES);
        Long abc1 = redisTemplate.opsForValue().increment("ABC1", 1);
        redisTemplate.expire("ABC",1, TimeUnit.MINUTES);
        return "访问结果：ABC1="+abc1;
    }
}
